package br.poli.ecomp.tcc.stimultimidia.view
{
	import br.poli.ecomp.tcc.stimultimidia.ApplicationFacade;
	import br.poli.ecomp.tcc.stimultimidia.event.TelaLoginEvent;
	import br.poli.ecomp.tcc.stimultimidia.model.vo.*;
	import br.poli.ecomp.tcc.stimultimidia.notification.TelaNotification;
	import br.poli.ecomp.tcc.stimultimidia.view.components.TelaLogin;
	
	import flash.events.Event;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class TelaLoginMediator extends Mediator implements IMediator
	{
		

		public static const NAME:String = 'TelaLoginMediatorMediator';
		
		
		public function  TelaLoginMediator(viewComponent:Object=null)
		{
			super(NAME, viewComponent);
			// Add Listeners
			
			telaLogin.addEventListener(TelaLoginEvent.SIGNUP , onSignUp)
			telaLogin.addEventListener(TelaLoginEvent.LOGIN , onLogin)
			
		}
		
		private function onLogin(e:TelaLoginEvent):void
		{
			//
			var user:UsuarioVO = e.user as UsuarioVO;
			sendNotification( ApplicationFacade.LOGIN, user );
		}
		
		
		private function onSignUp(e:TelaLoginEvent):void
		{
			sendNotification( TelaNotification.ABRIR_TELA_CADASTRO );
		}
		
		
		public function get telaLogin():TelaLogin{
			return viewComponent as TelaLogin;
		}		
		
		
		
		override public function listNotificationInterests():Array
		{
			return [
				 
			 ];
		}
		
		override public function handleNotification(notification:INotification):void
		{
			
			switch ( notification.getName() )
			{
				
				
				
		default : break;
			}
				
		}
		
	}
}